home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / GameKit / gamekit-1 / GameActor.m < prev    next >
Text File  |  1995-06-12  |  1KB  |  74 lines

  1.  
  2. /* Generated by Interface Builder */
  3.  
  4. // Handles moving and rendering various moving objects.
  5.  
  6. #import <gamekit/gamekit.h>
  7. #import <stdio.h>
  8.  
  9.  
  10. @implementation GameActor
  11.  
  12. - init                // initialize the new instance vars
  13. {
  14.     [super init];
  15.     myX = 0; myY = 0;
  16.     lastx = 0; lasty = 0;
  17.     px = 0; py = 0; scale = 1;
  18.     return self;
  19. }
  20.  
  21. - move:sender                // Move the Actor one animation frame
  22. {    // you must override this and put something here
  23.     return self;
  24. }
  25.  
  26. - at:(float *)xx :(float *)yy        // where is the actor now?
  27. {
  28.     *xx = myX;
  29.     *yy = myY;
  30.     return self;
  31. }
  32.  
  33. - lastAt:(float *)xx :(float *)yy    // called to find out where actor is
  34. {
  35.     *xx = lastx;
  36.     *yy = lasty;
  37.     return self;
  38. }
  39.  
  40. - (int)xpos { return myX; }    // return our x-coord
  41.  
  42. - (int)ypos { return myY; }    // return our y-coord
  43.  
  44. - moveOneFrame    // moves the actor along; access directly or via renderAt::move:
  45. {
  46.     myX += px;
  47.     myY += py;
  48.     return self;
  49. }
  50.  
  51. - renderAt:(int)posx :(int)posy move:(BOOL)moveOk    // draw actor
  52.         // you should lock focus on view that gets the actor first.
  53. {        // this should be overridden by the actor subclass
  54.     if (moveOk) [self moveOneFrame];
  55.     lastx = myX;
  56.     lasty = myY;
  57.     return self;
  58. }
  59.  
  60. - (int)scale
  61. {
  62.     return scale;
  63. }
  64.  
  65. - setScale:(int)newScale
  66. {
  67.     if ((newScale < 1) || (newScale > 2)) return self;
  68.     scale = newScale;
  69.     return self;
  70. }
  71.  
  72.  
  73. @end
  74.